package ir.values.users.instructions.jump;

import ir.types.Type;
import ir.types.datatypes.VoidType;
import ir.values.BasicBlock;
import ir.values.users.instructions.InstOperator;
import ir.values.users.instructions.Instruction;

public class UnconditionalBrInst extends JumpInst {
    private final BasicBlock targetBlock;
    public UnconditionalBrInst(BasicBlock targetBasicBlock) {
        super(VoidType.VOID);
        this.targetBlock = targetBasicBlock;
        operands.add(targetBasicBlock);
    }

    @Override
    public String parseLLVM() {
        StringBuilder sb = new StringBuilder();
        sb
                .append(getInstOperator())
                .append(" ")
                .append(targetBlock.getType())
                .append(" ")
                .append(targetBlock.parseUsingName());
        return sb.toString();
    }

    @Override
    public InstOperator getInstOperator() {
        return InstOperator.br;
    }
    @Override
    public boolean shouldGenerateId() {
        return false;
    }
}
